<template>
	<view style="display: flex;flex-direction: column;">
		<!-- 我发送的 -->
		<div style="display: flex;flex-direction: column;"v-for="(item,index) in list">
				<div style="display: flex;flex-direction: row;padding: 20rpx 0;width: 90%;
				margin: 25rpx;justify-content: flex-end;word-wrap: break-word;word-break: break-all;
				overflow: hidden;" v-if="item.type==2">
					<div style="background-color: #00ff7f;border-radius: 30rpx;
				padding: 20rpx;margin-right: 20rpx;">{{item.content}}</div>
					<img src="/static/帅哥.jpg" style="width: 70rpx;height: 70rpx;border-radius: 20rpx;">
				</div>
				<!-- 别人发给我的 -->
			<div style="display: flex;flex-direction: row;padding: 20rpx 0;width: 90%;
			margin: 25rpx;word-wrap: break-word;word-break: break-all;overflow: hidden;"v-if="item.type==1">
				<img src="/static/邀请有礼.png" style="width: 70rpx;height: 70rpx;">
				<div style="width: 630rpx;">
					<div style="background-color: #ffaa00;border-radius: 30rpx;padding: 20rpx;margin-left: 20rpx;">{{item.content}}</div>
				</div>
			</div>
		</div>
		<view style="position: absolute;bottom: 0;width:100vw ;height: 50px;background-color: #d9d9d9;display: flex;flex-direction: row;justify-content: center;align-items: center;" >
					<input style="flex: 1;margin-left: 20rpx;margin-right: 20rpx; height: 40px;border-radius: 20px;padding-left: 10px;background-color: #ffffff;"
						placeholder="请输入发送的内容" v-model="msg" />
					<view style="padding: 20rpx;background-color: #ffaa00;border-radius: 20rpx;margin-right: 20rpx;height: 40rpx;"  @click="hhh">发送</view>
				</view>
		<!-- <div style="position: absolute;bottom: 0;width: 100vw;display: flex;height: 70rpx;
		flex-direction: row;justify-content: center;" >
		<div style="width: 100%;display: flex;flex-direction: row;">
			<input style="flex: 1;height: 50rpx;margin-left: 20rpx;margin-right: 20rpx;border-radius: 40rpx;
			padding-left: 20rpx;" placeholder="请输入发送的内容" v-model="msg">
			<div style=" border-radius:10rpx;padding: 20rpx;" @click="hhh">发送</div>
			</div>
		</div> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				msg: '', //接收输入框的内容
								list: [
									// {
									// 	type:1,//表示这是别人发给我的
									// 	content:'这是别人发我的'
									// },
									// {
									// 	type:2,//表示这是我发给别人的
									// 	content:'这是我发给别人的'
									// }
								]//存消息的一个数据
			}
		},
		methods: {
			hhh(){
				this.list.push({
					type:2,
					content: this.msg
				})//往数组里添加数据
				uni.showLoading({
					title:'发送中'
				})
				uni.request({
					url:'https://api.lolimi.cn/API/AI/jj.php?msg=你好'+this.msg,
					success: (res) => {
						console.log(res)
						uni.hideLoading()
						this.msg = ''
						this.list.push({
							type:1,
							content: res.data.data.output
						})//往数组里添加数据
					}
				})
			}
		}
	}

</script>

<style>

</style>

